<%@ page import="njust.edu.web.Cart" %>
<%@ page import="njust.edu.entity.Dish" %>
<%@ page import="java.util.List" %>
<%@ page import="njust.edu.web.CartItem" %>
<%@ page import="njust.edu.entity.User" %><%--
  Created by IntelliJ IDEA.
  User: 陈
  Date: 2021/9/18
  Time: 16:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <title>购物车界面</title>
    <style>
        .cart_tip{
            /*display: none;*/
            background-color: 		#E8E8E8;
            opacity: 0.7;
            position: relative;
            float:left;
            position:relative;
            width:1650px;
            height:850px;
            left:50px;
            align-self: center;
            overflow: auto;
            padding-top: 350px;
            padding-left: 640px;
        }
        a:link {text-decoration:none;}
        a:visited {text-decoration:none;color: white;}
        a:active {text-decoration:none;}
        a:hover {text-decoration:none;color: #33CCFF;}
        p{
            font-family:georgia;
            font-weight: 400;
        }
        .header {
            font-size: 140%;
            opacity: 0.8;
            position: absolute;
            top: 0;
            width: 100%;
            height: 80px;
        }
        .header ul {
            list-style-type: none;
            background-color:	#101010;
            margin: 0;
            padding: 0;
            overflow: hidden;
            width: 100%;
            height: 80px;
        }

        .header li {
            float: left;
            height: 80px;
            width: 200px;
        }

        .header li a {
            display: block;
            color: white;
            text-align: center;
            padding: 30px;
            text-decoration: none;
            height: 80px;
        }

        .header li a:hover:not(.active) {
            background-color: #585858;
        }
        ul.nav-tabs li.active a, ul.nav-tabs li.active a:hover{
            color: #fff;
            background: #0088cc;
        }
        .container{

            left: 300px;
            position:absolute;
            width:1800px;
            height:1100px;
            top:80px;
            align-self: center;
            /* 	  background-color: lightgreen; */
        }
        .catalogue{
            color: white;
            background-color: #383838;
            opacity: 0.8;
            position:relative;
            width:1650px;
            height:80px;
            left:50px;
            align-self: center;
            /* 	  background-color: wheat; */
        }
        .dish_cata{
            position: relative;
            float: left;
            height: 60px;
            top: 10px;
            /* 	background-color: white; */
            margin-left: 20px;
            margin-right: 20px;
            padding-top: 20px;
            font-size: 150%;
            text-align: center;
        }
        .cart_list{
            color: #FF0000;
            background-color: 		#E8E8E8;
            opacity: 0.7;
            position:relative;
            width:1650px;
            height:850px;
            left:50px;
            align-self: center;
            overflow: auto;
            /* 	background-color: white; */
        }
        .cart_summary{
            background-color: 	#383838;
            opacity: 0.9;
            position:relative;
            width:1650px;
            height:160px;
            left:50px;
            border-bottom-left-radius: 30px;
            border-bottom-right-radius: 30px;
            color: white;
            overflow: auto;
        }
        .cart_remark{
            position:relative;
            width:600px;
            height:100px;
            left:30px;
            top:60px;
            overflow: auto;
            float: left;
            /* 	background-color: white; */
        }
        .cart_item{
            position:relative;
            width:1500px;
            height:240px;
            left:0px;
            align-self: center;
            overflow: auto;
            float: left;/*
	background-color: lightblue; */
            margin: 3px;
        }
        .dish_id{
            position:relative;
            width:50px;
            height:240px;
            left:0px;
            align-self: center;
            overflow: auto;
            float: left;
            /* 	background-color: yellow; */
            text-align: center;
            padding-top: 100px;
            font-size: 200%;
        }
        .dish_img{
            position:relative;
            width:300px;
            height:220px;
            left:50px;
            top: 20px;
            align-self: center;
            overflow: auto;
            float: left;
            /* 	background-color: white; */
        }
        .dish_name{
            position:relative;
            width:500px;
            height:100px;
            align-self: center;
            overflow: auto;
            /* 	background-color: yellow; */
            padding-left: 30px;
            padding-top: 20px;
            font-size: 300%;
            float: left;
        }
        .dish_price{
            position:relative;
            width:500px;
            height:100px;
            align-self: center;
            overflow: auto;
            /* 	background-color: darkorange; */
            padding-left: 30px;
            padding-top: 40px;
            font-size: 220%;
            float: left;
        }
        .dish_inf{
            position:relative;
            width:520px;
            height:200px;
            top: 20px;
            left: 60px;
            overflow: auto;
            float: left;
            /* 	background-color: wheat; */
        }
        .dish_num{
            position:relative;
            width:200px;
            height:70px;
            top: 80px;
            left: 60px;
            overflow: auto;
            padding-top: 20px;
            padding-left: 20px;
            float: left;
            /* 	background-color: white; */
        }
        a.change_quantity{
            position:relative;
            width:40px;
            height:40px;
            overflow: auto;
            float: left;
            font-weight: 700;
            display: block;
            margin-left: 15px;
            margin-right: 15px;
            text-align: center;
            background-color: white;
            color: black;
            border-radius: 20px;
            border-style: solid;
            border-width: 1px;
        }
        .input_quantity{
            position:relative;
            width: 30px;
            height: 40px;
            float: left;
            outline: none;
            border-style: none;
            font-size: 130%;
            text-align: center;
        }
        .item_price{
            position:relative;
            width:200px;
            height:70px;
            top: 80px;
            left: 160px;
            overflow: auto;
            float: left;
            padding-left: 30px;
            padding-top: 10px;
            font-size: 220%;
        }
        .cart_price{
            position:relative;
            width:260px;
            height:60px;
            top: 60px;
            left: 500px;
            overflow: auto;
            float: left;
            /* 	background-color: white; */
            font-size: 220%;
        }
        .cart_confirm{
            position:relative;
            width:220px;
            height:80px;
            top: 40px;
            left: 520px;
            overflow: auto;
            float: left;
            font-size: 170%;
            border-radius: 20px;
            display: block;
            text-align: center;
            /*padding-top: 25px;*/
            border-style: solid;
            border-width: 6px;
            color: #33CCFF;
            background-color: 	#686868;
            border-color:  #33CCFF;
        }
        a:link {text-decoration:none;}
        a:visited {text-decoration:none;}
        a:hover {text-decoration:none;}
        a:active {text-decoration:none;}
        #user_name{
            width: 700px;
        }
        #table_ID{
            width: 100px;
        }
        #user_num{
            width: 250px;
        }
        #dish_allprice{
            width: 250px;
        }
        #item_searchchoise{
            color: black;
            width: 160px;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            background-color: #f1f1f1;
            font-size: 100%;
            height: 50px;
            float: left;
        }
        select option{
            font-size: 110%;
        }

    </style>
</head>
<body>
<div class = "backGround" style="position: relative;">
    <img src = "../img/cart.jpg" width="2402px" height="1202px" style="align-self: center">
    <div class="header">
    <ul>
        <li><a href="BookController?method=allDishList">菜单</a></li>
        <li><a href="CartController?method=toCartUI">购物车</a></li>
        <li><a href="TradeController?method=toTradeAllUI">订单</a></li>
        <li style="float: right"><a href="index.jsp" ><p>退出登录</p></a></li>
    </ul>
</div>

    <div class = "container">
        <form action="TradeController?method=addTrade" style="" method="post">
        <%
            User user = (User) request.getAttribute("user");
        %>
        <div class = "catalogue">
            <div class = "dish_cata" id = "user_name">用户名: <%=user.getName()%></div>
            <div class = "dish_cata" id = "table_ID">桌号</div>
            <div class = "dish_cata"style="padding-top: 15px;">
                <input type="text" name="tableNum" style="color: black">
            </div>
        </div>
        <%
            Cart cart = (Cart)session.getAttribute("cart");
            if (cart==null || cart.getTotalNumber()==0)
            {
        %>
            <div class = "cart_tip">
                <p style="font-size: 300%; font-weight: 600;">您的购物车为空！</p>
            </div>
        <%}
            else{
        %>
            <div class= "cart_list" >
            <%
                List<CartItem> cartItemList = cart.getItems();
                int count=1;
                for (CartItem cartItem:cartItemList){
            %>
                <div class = "cart_item" >
                    <div class = "dish_id"><%=count%></div>
                    <div class = "dish_img">
                        <img src="../img/<%=cartItem.getDish().getPicture()%>" width="300px" height="200px">
                    </div>
                    <div class = "dish_inf">
                        <div class = "dish_name"><p><%=cartItem.getDish().getName()%></p></div>
                        <div class = "dish_price"><p><%=cartItem.getDish().getPrice()%>元</p></div>
                    </div>
                    <div class = "dish_num">
                        <a href="CartController?method=cartItemDelete&id=<%=cartItem.getDish().getId()%>"class = "change_quantity" id = "reduce_quantity" style="font-size: 190%; font-weight: 600;">-</a>
                        <input type="text" class="input_quantity" value="<%=cartItem.getQuantity()%>" oninput="value=value.replace(/[^\d]/g,'')">
                        <a href="CartController?method=cartItemAdd&id=<%=cartItem.getDish().getId()%>" class = "change_quantity" id = "add_quantity" style="font-size: 190%; font-weight: 500;" >+</a>

                    </div>

                    <div class = "item_price" id="item_price_<%=count%>"><p><%=cartItem.getMoney()%>元</p></div>

                    <hr color="#000000" >
                </div>
                <%
                        count++;
                    }
                %>
            </div>

        <div class= "cart_summary" >
            <div class="cart_remark">
                <p style="float: left; font-size: 200%; font-weight: 100;">备注：</p>
                <input type="text" style="float: left; font-size: 200%; font-weight: 100; width: 300px;height: 40px;border-style: solid;"
                       class="" value="" >

            </div>
    <%--        <div ><%=cart.getTotalNumber()%></div>--%>
            <div class="cart_price"><p><%=cart.getTotalMoney()%>元</p></div>
<%--            <a class = "cart_confirm" href="TradeController?method=addTrade">确认订单</a>--%>
            <input type="submit" value="确认订单" class = "cart_confirm">
        </div>
        <%
            }
        %>
        </form>
    </div>

</div>
</body>
</html>
